<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../../../课件/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				var page = '01.txt';
				get(page);
				
				// 获取数据
				function get(page){
					$('table tr:first').siblings().remove()
					$.get( page,function(data){
						console.log(data);
						data = JSON.parse(data);
	                	for(var i=0; i<data.datagrid.data.rows.length;i++){
	                		var currRow = data.datagrid.data.rows[i];
	                		var $tr = $('<tr></tr>');
	                		$tr.html($tr.html() + '<td>' + $('table tr').length + '</td>');
	                		$tr.html($tr.html() + '<td>' + currRow.RowData.suname.DisPlayValue + '</td>');
	                		$tr.html($tr.html() + '<td>' + currRow.RowData.suaddress.DisPlayValue + '</td>')
	                		$tr.html($tr.html() + '<td>' + currRow.RowData.contact.DisPlayValue + '</td>')
	                		$tr.html($tr.html() + '<td>' + currRow.RowData.suphone.DisPlayValue + '</td>')
	                		$('#table').append($tr);
	                	}
					})
				}
				
				// 换页
				$('#box input').each(function(index){
					$(this).click(function(){
						page = "0" + (index + 1) + ".txt";
						get(page);
					})
				})
				
				//  查找
				$('#search').click(function(){
					var $val = $('#keyword').val();
					console.log('aaa');
					for(var i = 0; i < $('#box input').length; i++){
						page = '0'+(i+1)+'.txt';
						console.log(page);
						$('table tr:first').siblings().remove()
						$.get( page,function(data){
							console.log(data);
							data = JSON.parse(data);
		                	for(var i=0; i<data.datagrid.data.rows.length;i++){
		                		var currRow = data.datagrid.data.rows[i];
		                		if(currRow.RowData.suname.DisPlayValue.match($val)){
//		                			$val.test(/广州/)
//		                			var reg = /广州/gi;
//		                			reg.match($val)
//		                		if(/广州/gi.test(currRow.RowData.suname.DisPlayValue)){
		                			var $tr = $('<tr></tr>');
			                		$tr.html($tr.html() + '<td>' + $('table tr').length + '</td>');
			                		$tr.html($tr.html() + '<td>' + currRow.RowData.suname.DisPlayValue + '</td>');
			                		$tr.html($tr.html() + '<td>' + currRow.RowData.suaddress.DisPlayValue + '</td>')
			                		$tr.html($tr.html() + '<td>' + currRow.RowData.contact.DisPlayValue + '</td>')
			                		$tr.html($tr.html() + '<td>' + currRow.RowData.suphone.DisPlayValue + '</td>')
			                		$('#table').append($tr);
			                	}
		                		
		                	}		                	
						})
					}
					
				})
			})
		</script>
	</head>
	<body>
	    <div id="">
	    	<input type="text" name="" id="keyword" value="" />
			<input type="button" name="" id="search" value="查找" />
	    </div>
	    <br />
		<table  id="table" border=""  style="text-align: center;" cellspacing="0" cellpadding="0">
			<tr><th style="width: 40px;">序号</th><th style="width: 400px;">供应商名称</th><th style="width: 400px;">供应商地址</th><th style="width: 200px;">供应商联系人</th><th style="width: 200px;">供应商电话</th></tr>
				
		</table>
		<br />
		<div id="box">
			<input type="button" name="" id="" value="1" />
			<input type="button" name="" id="" value="2" />
			<input type="button" name="" id="" value="3" />
			<input type="button" name="" id="" value="4" />
			<input type="button" name="" id="" value="5" />
			<input type="button" name="" id="" value="6" />
			<input type="button" name="" id="" value="7" />
			<input type="button" name="" id="" value="8" />
			<input type="button" name="" id="" value="9" />
		</div>
			
	</body>
</html>
